package com.modi.breaks;

import java.awt.Dimension;
import java.awt.Label;
import java.awt.Toolkit;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;

public class MainFrame extends JFrame {

	/** 
          *  
          */
	private static final long serialVersionUID = 1L;
	public static final MainFrame INSTANCE = new MainFrame();

	private MainFrame() {
		setSize(300, 300);
		setVisible(true);
		toFront();

		setTitle("Stretch Breaks");
		setDefaultCloseOperation(EXIT_ON_CLOSE);

		Toolkit toolkit = getToolkit();
		Dimension size = toolkit.getScreenSize();
		setLocation(size.width / 2 - getWidth() / 2, size.height / 2
				- getHeight() / 2);

		JPanel panel = new JPanel();
		getContentPane().add(panel);

		final JButton stopButton = new JButton("Stop");
		final JButton startButton = new JButton("Start");
		startButton.setBounds(50, 60, 80, 30);
		startButton.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent event) {
				startButton.setEnabled(false);
				stopButton.setEnabled(true);
				System.out.println("startButton---------" + DateUtils.now());
				StretchScheduler scheduler = new StretchScheduler();
				scheduler.startTheScheduler();
				Main.scheduler = scheduler;
				

			}
		});
		
		
		stopButton.setEnabled(false);
		stopButton.setBounds(70, 80, 100, 50);
		stopButton.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent event) {
				stopButton.setEnabled(false);
				startButton.setEnabled(true);
				System.out.println("stopbutton---------" + DateUtils.now());
				if(null != Main.scheduler){
					Main.scheduler.stopTheScheduler();
				}
				

			}
		});
		
		panel.add(startButton);
		panel.add(stopButton);

	}
}
